<?php include_partial('aoiFrontPartials/contentHeader',
  array(
    'nav'=>array(
      array('url'=>url_for('admin_home'),'title'=>'Admin'),
      array('url'=>'','title'=>'R&eacute;servations')
    ),
    'title'=>'R&eacute;servations',
    'description'=>'Votre prochain voyage avec Comoros Airways'
  )
); ?>


<section id="content">
  <div class="container">
    
    <div id="mainbody">
      
      <div class="row">
        <div class="span12">

          <h1>Aoi itinerary reservations List</h1>
          <form method="get" action="<?php echo url_for('admin_reservations') ?>">
            <fieldset>
          <select name="status">
            <option value="">All statuses</option>
            <option value="created"<?php if($status == 'created') echo ' selected'; ?>>New</option>
            <option value="pending"<?php if($status == 'pending') echo ' selected'; ?>>Payment pending</option>
            <option value="validated"<?php if($status == 'validated') echo ' selected'; ?>>Payment validated</option>
            <option value="cancelled"<?php if($status == 'cancelled') echo ' selected'; ?>>Cancelled</option>
          </select>
          <select name="flights">
            <option value="">Future flights only</option>
            <option value="all"<?php if($flights == 'all') echo ' selected'; ?>>All flights</option>
            <option value="past"<?php if($flights == 'past') echo ' selected'; ?>>Past flights</option>
          </select>
          <input type="text" name="ref_code" placeholder="Search reference" value="<?php echo $ref_code ?>"/>
          <input type="text" name="ticket_code" placeholder="Passenger ticket code" value="<?php echo $ticket_code ?>"/>
            <button class="btn btn-success">search</button>
          </fieldset>
          </form>
          <?php if(count($reservations->getRawValue()) > 0): ?>
          <table class="table table-striped">
            <thead>
              <tr>
                <th>Ref code</th>
                <th>Contact firstname</th>
                <th>Contact lastname</th>
                <th>Contact email</th>
                <th>Flight codes</th>
                <th>Status</th>
                <th>Amount</th>
                <th>Created at</th>
              </tr>
            </thead>
            <tbody>
              <?php foreach($reservations->getRawValue() as $reservation): ?>
              <tr class="reservation <?php echo $reservation['status'] ?>">
                <td>
                  <a href="<?php echo url_for('admin_reservations_edit',array('action'=>'edit','id'=>$reservation['id'])) ?>">
                    <?php echo $reservation['ref_code'] ?>
                  </a>
                </td>
                <td>
                    <?php echo $reservation['contact_firstname'] ?>
                </td>
                <td>
                    <?php echo $reservation['contact_lastname'] ?>
                </td>
                <td>
                    <?php echo $reservation['contact_email'] ?>
                </td>
                <td>
                    <?php echo $reservation['flight_codes'] ?>
                </td>
                <td>
                    <?php echo $reservation['status'] ?>
                </td>
                <td>
                    <?php echo $reservation['amount'] ?>
                </td>
                <td>
                    <?php echo $reservation['created_at'] ?>
                </td>
              </tr>
              <?php endforeach;?>
            </tbody>
          </table>
          <?php else: ?>
          <p>No reservations found</p>
          <?php endif; ?>
        </div> <!-- end span12 -->
      </div><!-- end row -->
      
    </div><!-- end mainbody -->
    
  </div><!-- end container -->
</section>
